<?php
require_once __DIR__ . '/../variant/start.php';

$server = new Swoole\Server("127.0.0.1", 9502);

$process = new Swoole\Process(function ($process) use ($server) {
    (new \app\server\amqp\controller\Im($server))->index();
    $server->reload();
});

$server->addProcess($process);

//监听连接进入事件
$server->on('Connect', function ($server, $fd) {
    echo "Client: Connect.\n";
});

//监听数据接收事件
$server->on('Receive', function ($server, $fd, $from_id, $data) {
    $server->send($fd, "Server: " . $data);
});

//监听连接关闭事件
$server->on('Close', function ($server, $fd) {
    echo "Client: Close.\n";
});

//启动服务器
$server->start();